home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Development Kits / Mac OS / USB DDK 1.4.6f4 / Interfaces / USB.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-26  |  53.9 KB  |  2,092 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:       USB.h
  3.  
  4.      Contains:   Public API for USB Services Library (and associated components)
  5.  
  6.      Version:    USB 1.4.6
  7.  
  8. */
  9. #ifndef __USB__
  10. #define __USB__
  11.  
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15.  
  16. #ifndef __NAMEREGISTRY__
  17. #include <NameRegistry.h>
  18. #endif
  19.  
  20. #ifndef __CODEFRAGMENTS__
  21. #include <CodeFragments.h>
  22. #endif
  23.  
  24. #ifndef __DEVICES__
  25. #include <Devices.h>
  26. #endif
  27.  
  28. #ifndef __MACERRORS__
  29. #include <MacErrors.h>
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55. /* ************* Constants ************* */
  56.  
  57. enum {
  58.                                         /* Flags */
  59.   kUSBTaskTimeFlag              = 1,
  60.   kUSBHubPower                  = 2,
  61.   kUSBPowerReset                = 4,
  62.   kUSBHubReaddress              = 8,
  63.   kUSBAddressRequest            = 16,
  64.   kUSBReturnOnException         = 32,
  65.   kUSBNo5SecTimeout             = 64,
  66.   kUSBTimeout                   = 128,
  67.   kUSBNoDataTimeout             = 256,
  68.   kUSBDebugAwareFlag            = 512,
  69.   kUSBResetDescriptorCache      = 1024
  70. };
  71.  
  72. enum {
  73.                                         /* Hub messages */
  74.   kUSBHubPortResetRequest       = 1,
  75.   kUSBHubPortSuspendRequest     = 2,
  76.   kUSBHubPortStatusRequest      = 3
  77. };
  78.  
  79. enum {
  80.   kVendorID_AppleComputer       = 0x05AC
  81. };
  82.  
  83. /* ************* types ************* */
  84.  
  85. typedef SInt32                          USBReference;
  86. typedef USBReference                    USBDeviceRef;
  87. typedef USBDeviceRef *                  USBDeviceRefPtr;
  88. typedef USBReference                    USBInterfaceRef;
  89. typedef USBReference                    USBPipeRef;
  90. typedef USBReference                    USBBusRef;
  91. typedef UInt32                          USBPipeState;
  92. typedef UInt32                          USBCount;
  93. typedef UInt32                          USBFlags;
  94. typedef UInt8                           USBRequest;
  95. typedef UInt8                           USBDirection;
  96. typedef UInt8                           USBRqRecipient;
  97. typedef UInt8                           USBRqType;
  98. typedef UInt16                          USBRqIndex;
  99. typedef UInt16                          USBRqValue;
  100.  
  101.  
  102.  
  103. struct usbControlBits {
  104.   UInt8               BMRequestType;
  105.   UInt8               BRequest;
  106.   USBRqValue          WValue;
  107.   USBRqIndex          WIndex;
  108.   UInt16              reserved4;
  109. };
  110. typedef struct usbControlBits           usbControlBits;
  111.  
  112. struct USBIsocFrame {
  113.   OSStatus            frStatus;
  114.   UInt16              frReqCount;
  115.   UInt16              frActCount;
  116. };
  117. typedef struct USBIsocFrame             USBIsocFrame;
  118. enum {
  119.   kUSBMaxIsocFrameReqCount      = 1023  /* maximum size (bytes) of any one Isoc frame*/
  120. };
  121.  
  122.  
  123. struct usbIsocBits {
  124.   USBIsocFrame *      FrameList;
  125.   UInt32              NumFrames;
  126. };
  127. typedef struct usbIsocBits              usbIsocBits;
  128.  
  129. struct usbHubBits {
  130.   UInt32              Request;
  131.   UInt32              Spare;
  132. };
  133. typedef struct usbHubBits               usbHubBits;
  134. typedef struct USBPB                    USBPB;
  135. typedef CALLBACK_API_C( void , USBCompletion )(USBPB *pb);
  136.  
  137. union USBVariantBits {
  138.   usbControlBits      cntl;
  139.   usbIsocBits         isoc;
  140.   usbHubBits          hub;
  141. };
  142. typedef union USBVariantBits            USBVariantBits;
  143.  
  144. struct USBPB {
  145.  
  146.   void *              qlink;
  147.   UInt16              qType;
  148.   UInt16              pbLength;
  149.   UInt16              pbVersion;
  150.   UInt16              reserved1;
  151.   UInt32              reserved2;
  152.  
  153.   OSStatus            usbStatus;
  154.   USBCompletion       usbCompletion;
  155.   UInt32              usbRefcon;
  156.  
  157.   USBReference        usbReference;
  158.  
  159.   void *              usbBuffer;
  160.   USBCount            usbReqCount;
  161.   USBCount            usbActCount;
  162.  
  163.   USBFlags            usbFlags;
  164.  
  165.   USBVariantBits      usb;
  166.  
  167.   UInt32              usbFrame;
  168.  
  169.   UInt8               usbClassType;
  170.   UInt8               usbSubclass;
  171.   UInt8               usbProtocol;
  172.   UInt8               usbOther;
  173.  
  174.   UInt32              reserved6;
  175.   UInt16              reserved7;
  176.   UInt16              reserved8;
  177.  
  178. };
  179.  
  180.  
  181. typedef USBPB *                         USBPBPtr;
  182. #if !defined(OLDUSBNAMES)
  183. #define OLDUSBNAMES 0
  184. #endif
  185.  
  186. #if OLDUSBNAMES
  187. #define usbBMRequestType  usb.cntl.BMRequestType
  188. #define usbBRequest       usb.cntl.BRequest
  189. #define usbWValue         usb.cntl.WValue
  190. #define usbWIndex         usb.cntl.WIndex
  191. #endif
  192.  
  193. struct uslReq {
  194.   USBDirection        usbDirection;
  195.   USBRqType           usbType;
  196.   USBRqRecipient      usbRecipient;
  197.   USBRequest          usbRequest;
  198. };
  199. typedef struct uslReq                   uslReq;
  200.  
  201. enum {
  202.                                         /* BT 19Aug98, bump up to v1.10 for Isoc*/
  203.   kUSBCurrentPBVersion          = 0x0100, /* v1.00*/
  204.   kUSBIsocPBVersion             = 0x0109, /* v1.10*/
  205.   kUSBCurrentHubPB              = kUSBIsocPBVersion
  206. };
  207.  
  208.  
  209.  
  210.  
  211. #define kUSBNoCallBack ((USBCompletion)-1L)
  212.  
  213.  
  214. typedef UInt8                           bcdUSB;
  215. enum {
  216.   kUSBControl                   = 0,
  217.   kUSBIsoc                      = 1,
  218.   kUSBBulk                      = 2,
  219.   kUSBInterrupt                 = 3,
  220.   kUSBAnyType                   = 0xFF
  221. };
  222.  
  223. /* endpoint type */
  224. enum {
  225.   kUSBOut                       = 0,
  226.   kUSBIn                        = 1,
  227.   kUSBNone                      = 2,
  228.   kUSBAnyDirn                   = 3
  229. };
  230.  
  231. /*USBDirection*/
  232. enum {
  233.   kUSBStandard                  = 0,
  234.   kUSBClass                     = 1,
  235.   kUSBVendor                    = 2
  236. };
  237.  
  238. /*USBRqType*/
  239. enum {
  240.   kUSBDevice                    = 0,
  241.   kUSBInterface                 = 1,
  242.   kUSBEndpoint                  = 2,
  243.   kUSBOther                     = 3
  244. };
  245.  
  246. /*USBRqRecipient*/
  247. enum {
  248.   kUSBRqGetStatus               = 0,
  249.   kUSBRqClearFeature            = 1,
  250.   kUSBRqReserved1               = 2,
  251.   kUSBRqSetFeature              = 3,
  252.   kUSBRqReserved2               = 4,
  253.   kUSBRqSetAddress              = 5,
  254.   kUSBRqGetDescriptor           = 6,
  255.   kUSBRqSetDescriptor           = 7,
  256.   kUSBRqGetConfig               = 8,
  257.   kUSBRqSetConfig               = 9,
  258.   kUSBRqGetInterface            = 10,
  259.   kUSBRqSetInterface            = 11,
  260.   kUSBRqSyncFrame               = 12
  261. };
  262.  
  263. /*USBRequest*/
  264.  
  265. enum {
  266.   kUSBDeviceDesc                = 1,
  267.   kUSBConfDesc                  = 2,
  268.   kUSBStringDesc                = 3,
  269.   kUSBInterfaceDesc             = 4,
  270.   kUSBEndpointDesc              = 5,
  271.   kUSBHIDDesc                   = 0x21,
  272.   kUSBReportDesc                = 0x22,
  273.   kUSBPhysicalDesc              = 0x23,
  274.   kUSBHUBDesc                   = 0x29
  275. };
  276.  
  277. /* descriptorType */
  278.  
  279. enum {
  280.   kUSBFeatureDeviceRemoteWakeup = 1,
  281.   kUSBFeatureEndpointStall      = 0
  282. };
  283.  
  284. /* Feature selectors */
  285. enum {
  286.   kUSBActive                    = 0,    /* Pipe can accept new transactions*/
  287.   kUSBIdle                      = 1,    /* Pipe will not accept new transactions*/
  288.   kUSBStalled                   = 2,    /* An error occured on the pipe*/
  289.   kUSBSuspended                 = 4,    /* Device is suspended*/
  290.   kUSBNoBandwidth               = 8     /* (Isoc or Int) Pipe could not be initialised due to bandwidth constraint*/
  291. };
  292.  
  293. enum {
  294.   kUSB100mAAvailable            = 50,
  295.   kUSB500mAAvailable            = 250,
  296.   kUSB100mA                     = 50,
  297.   kUSBAtrBusPowered             = 0x80,
  298.   kUSBAtrSelfPowered            = 0x40,
  299.   kUSBAtrRemoteWakeup           = 0x20
  300. };
  301.  
  302. enum {
  303.   kUSBRel10                     = 0x0100
  304. };
  305.  
  306. #define USB_CONSTANT16(x)   ((((x) >> 8) & 0x0ff) | ((x & 0xff) << 8))
  307. enum {
  308.   kUSBDeviceDescriptorLength    = 0x12,
  309.   kUSBInterfaceDescriptorLength = 0x09,
  310.   kUSBConfigDescriptorLength    = 0x09
  311. };
  312.  
  313.  
  314. struct USBDeviceDescriptor {
  315.   UInt8               length;
  316.   UInt8               descType;
  317.   UInt16              usbRel;
  318.   UInt8               deviceClass;
  319.   UInt8               deviceSubClass;
  320.   UInt8               protocol;
  321.   UInt8               maxPacketSize;
  322.   UInt16              vendor;
  323.   UInt16              product;
  324.   UInt16              devRel;
  325.   UInt8               manuIdx;
  326.   UInt8               prodIdx;
  327.   UInt8               serialIdx;
  328.   UInt8               numConf;
  329. };
  330. typedef struct USBDeviceDescriptor      USBDeviceDescriptor;
  331. typedef USBDeviceDescriptor *           USBDeviceDescriptorPtr;
  332.  
  333. struct USBDescriptorHeader {
  334.   UInt8               length;
  335.   UInt8               descriptorType;
  336. };
  337. typedef struct USBDescriptorHeader      USBDescriptorHeader;
  338. typedef USBDescriptorHeader *           USBDescriptorHeaderPtr;
  339.  
  340. struct USBConfigurationDescriptor {
  341.   UInt8               length;
  342.   UInt8               descriptorType;
  343.   UInt16              totalLength;
  344.   UInt8               numInterfaces;
  345.   UInt8               configValue;
  346.   UInt8               configStrIndex;
  347.   UInt8               attributes;
  348.   UInt8               maxPower;
  349. };
  350. typedef struct USBConfigurationDescriptor USBConfigurationDescriptor;
  351. typedef USBConfigurationDescriptor *    USBConfigurationDescriptorPtr;
  352.  
  353. struct USBInterfaceDescriptor {
  354.   UInt8               length;
  355.   UInt8               descriptorType;
  356.   UInt8               interfaceNumber;
  357.   UInt8               alternateSetting;
  358.   UInt8               numEndpoints;
  359.   UInt8               interfaceClass;
  360.   UInt8               interfaceSubClass;
  361.   UInt8               interfaceProtocol;
  362.   UInt8               interfaceStrIndex;
  363. };
  364. typedef struct USBInterfaceDescriptor   USBInterfaceDescriptor;
  365. typedef USBInterfaceDescriptor *        USBInterfaceDescriptorPtr;
  366.  
  367. struct USBEndPointDescriptor {
  368.   UInt8               length;
  369.   UInt8               descriptorType;
  370.   UInt8               endpointAddress;
  371.   UInt8               attributes;
  372.   UInt16              maxPacketSize;
  373.   UInt8               interval;
  374. };
  375. typedef struct USBEndPointDescriptor    USBEndPointDescriptor;
  376. typedef USBEndPointDescriptor *         USBEndPointDescriptorPtr;
  377.  
  378. struct USBHIDDescriptor {
  379.   UInt8               descLen;
  380.   UInt8               descType;
  381.   UInt16              descVersNum;
  382.   UInt8               hidCountryCode;
  383.   UInt8               hidNumDescriptors;
  384.   UInt8               hidDescriptorType;
  385.   UInt8               hidDescriptorLengthLo;  /* can't make this a single 16bit value or the compiler will add a filler byte*/
  386.   UInt8               hidDescriptorLengthHi;
  387. };
  388. typedef struct USBHIDDescriptor         USBHIDDescriptor;
  389. typedef USBHIDDescriptor *              USBHIDDescriptorPtr;
  390.  
  391. struct USBHIDReportDesc {
  392.   UInt8               hidDescriptorType;
  393.   UInt8               hidDescriptorLengthLo;  /* can't make this a single 16bit value or the compiler will add a filler byte*/
  394.   UInt8               hidDescriptorLengthHi;
  395. };
  396. typedef struct USBHIDReportDesc         USBHIDReportDesc;
  397. typedef USBHIDReportDesc *              USBHIDReportDescPtr;
  398.  
  399. struct USBHubPortStatus {
  400.   UInt16              portFlags;              /* Port status flags */
  401.   UInt16              portChangeFlags;        /* Port changed flags */
  402. };
  403. typedef struct USBHubPortStatus         USBHubPortStatus;
  404. typedef USBHubPortStatus *              USBHubPortStatusPtr;
  405. /* ********* ProtoTypes *************** */
  406. /* For dealing with endianisms */
  407. #if CALL_NOT_IN_CARBON
  408. /*
  409.  *  HostToUSBWord()
  410.  *  
  411.  *  Availability:
  412.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  413.  *    CarbonLib:        not available
  414.  *    Mac OS X:         not available
  415.  */
  416. EXTERN_API_C( UInt16 )
  417. HostToUSBWord( 
  418.   UInt16                  value);
  419.  
  420.  
  421. /*
  422.  *  USBToHostWord()
  423.  *  
  424.  *  Availability:
  425.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  426.  *    CarbonLib:        not available
  427.  *    Mac OS X:         not available
  428.  */
  429. EXTERN_API_C( UInt16 )
  430. USBToHostWord( 
  431.   UInt16                  value);
  432.  
  433.  
  434. /*
  435.  *  HostToUSBLong()
  436.  *  
  437.  *  Availability:
  438.  *    Non-Carbon CFM:   available in USBServicesLib 1.1 or later
  439.  *    CarbonLib:        not available
  440.  *    Mac OS X:         not available
  441.  */
  442. EXTERN_API_C( UInt32 )
  443. HostToUSBLong( 
  444.   UInt32                  value);
  445.  
  446.  
  447. /*
  448.  *  USBToHostLong()
  449.  *  
  450.  *  Availability:
  451.  *    Non-Carbon CFM:   available in USBServicesLib 1.1 or later
  452.  *    CarbonLib:        not available
  453.  *    Mac OS X:         not available
  454.  */
  455. EXTERN_API_C( UInt32 )
  456. USBToHostLong( 
  457.   UInt32                  value);
  458.  
  459.  
  460. /* Main prototypes */
  461. /* Transfer commands */
  462. /*
  463.  *  USBDeviceRequest()
  464.  *  
  465.  *  Availability:
  466.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  467.  *    CarbonLib:        not available
  468.  *    Mac OS X:         not available
  469.  */
  470. EXTERN_API_C( OSStatus )
  471. USBDeviceRequest( 
  472.   USBPB *                 pb);
  473.  
  474.  
  475. /*
  476.  *  USBBulkWrite()
  477.  *  
  478.  *  Availability:
  479.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  480.  *    CarbonLib:        not available
  481.  *    Mac OS X:         not available
  482.  */
  483. EXTERN_API_C( OSStatus )
  484. USBBulkWrite( 
  485.   USBPB *                 pb);
  486.  
  487.  
  488. /*
  489.  *  USBBulkRead()
  490.  *  
  491.  *  Availability:
  492.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  493.  *    CarbonLib:        not available
  494.  *    Mac OS X:         not available
  495.  */
  496. EXTERN_API_C( OSStatus )
  497. USBBulkRead( 
  498.   USBPB *                 pb);
  499.  
  500.  
  501. /*
  502.  *  USBIntRead()
  503.  *  
  504.  *  Availability:
  505.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  506.  *    CarbonLib:        not available
  507.  *    Mac OS X:         not available
  508.  */
  509. EXTERN_API_C( OSStatus )
  510. USBIntRead( 
  511.   USBPB *                 pb);
  512.  
  513.  
  514. /*
  515.  *  USBIntWrite()
  516.  *  
  517.  *  Availability:
  518.  *    Non-Carbon CFM:   available in USBServicesLib 1.2 or later
  519.  *    CarbonLib:        not available
  520.  *    Mac OS X:         not available
  521.  */
  522. EXTERN_API_C( OSStatus )
  523. USBIntWrite( 
  524.   USBPB *                 pb);
  525.  
  526.  
  527. /*
  528.  *  USBIsocRead()
  529.  *  
  530.  *  Availability:
  531.  *    Non-Carbon CFM:   available in USBServicesLib 1.1 or later
  532.  *    CarbonLib:        not available
  533.  *    Mac OS X:         not available
  534.  */
  535. EXTERN_API_C( OSStatus )
  536. USBIsocRead( 
  537.   USBPB *                 pb);
  538.  
  539.  
  540. /*
  541.  *  USBIsocWrite()
  542.  *  
  543.  *  Availability:
  544.  *    Non-Carbon CFM:   available in USBServicesLib 1.1 or later
  545.  *    CarbonLib:        not available
  546.  *    Mac OS X:         not available
  547.  */
  548. EXTERN_API_C( OSStatus )
  549. USBIsocWrite( 
  550.   USBPB *                 pb);
  551.  
  552.  
  553. /* Pipe state control */
  554. /*
  555.  *  USBClearPipeStallByReference()
  556.  *  
  557.  *  Availability:
  558.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  559.  *    CarbonLib:        not available
  560.  *    Mac OS X:         not available
  561.  */
  562. EXTERN_API_C( OSStatus )
  563. USBClearPipeStallByReference( 
  564.   USBPipeRef              ref);
  565.  
  566.  
  567. /*
  568.  *  USBAbortPipeByReference()
  569.  *  
  570.  *  Availability:
  571.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  572.  *    CarbonLib:        not available
  573.  *    Mac OS X:         not available
  574.  */
  575. EXTERN_API_C( OSStatus )
  576. USBAbortPipeByReference( 
  577.   USBReference            ref);
  578.  
  579.  
  580. /*
  581.  *  USBResetPipeByReference()
  582.  *  
  583.  *  Availability:
  584.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  585.  *    CarbonLib:        not available
  586.  *    Mac OS X:         not available
  587.  */
  588. EXTERN_API_C( OSStatus )
  589. USBResetPipeByReference( 
  590.   USBReference            ref);
  591.  
  592.  
  593. /*
  594.  *  USBSetPipeIdleByReference()
  595.  *  
  596.  *  Availability:
  597.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  598.  *    CarbonLib:        not available
  599.  *    Mac OS X:         not available
  600.  */
  601. EXTERN_API_C( OSStatus )
  602. USBSetPipeIdleByReference( 
  603.   USBPipeRef              ref);
  604.  
  605.  
  606. /*
  607.  *  USBSetPipeActiveByReference()
  608.  *  
  609.  *  Availability:
  610.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  611.  *    CarbonLib:        not available
  612.  *    Mac OS X:         not available
  613.  */
  614. EXTERN_API_C( OSStatus )
  615. USBSetPipeActiveByReference( 
  616.   USBPipeRef              ref);
  617.  
  618.  
  619. /*
  620.  *  USBClosePipeByReference()
  621.  *  
  622.  *  Availability:
  623.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  624.  *    CarbonLib:        not available
  625.  *    Mac OS X:         not available
  626.  */
  627. EXTERN_API_C( OSStatus )
  628. USBClosePipeByReference( 
  629.   USBPipeRef              ref);
  630.  
  631.  
  632. /*
  633.  *  USBGetPipeStatusByReference()
  634.  *  
  635.  *  Availability:
  636.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  637.  *    CarbonLib:        not available
  638.  *    Mac OS X:         not available
  639.  */
  640. EXTERN_API_C( OSStatus )
  641. USBGetPipeStatusByReference( 
  642.   USBReference            ref,
  643.   USBPipeState *          state);
  644.  
  645.  
  646.  
  647. /* Configuration services */
  648. /*
  649.  *  USBFindNextInterface()
  650.  *  
  651.  *  Availability:
  652.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  653.  *    CarbonLib:        not available
  654.  *    Mac OS X:         not available
  655.  */
  656. EXTERN_API_C( OSStatus )
  657. USBFindNextInterface( 
  658.   USBPB *                 pb);
  659.  
  660.  
  661. /*
  662.  *  USBOpenDevice()
  663.  *  
  664.  *  Availability:
  665.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  666.  *    CarbonLib:        not available
  667.  *    Mac OS X:         not available
  668.  */
  669. EXTERN_API_C( OSStatus )
  670. USBOpenDevice( 
  671.   USBPB *                 pb);
  672.  
  673.  
  674. /*
  675.  *  USBSetConfiguration()
  676.  *  
  677.  *  Availability:
  678.  *    Non-Carbon CFM:   available in USBServicesLib 1.1 or later
  679.  *    CarbonLib:        not available
  680.  *    Mac OS X:         not available
  681.  */
  682. EXTERN_API_C( OSStatus )
  683. USBSetConfiguration( 
  684.   USBPB *                 pb);
  685.  
  686.  
  687. /*
  688.  *  USBNewInterfaceRef()
  689.  *  
  690.  *  Availability:
  691.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  692.  *    CarbonLib:        not available
  693.  *    Mac OS X:         not available
  694.  */
  695. EXTERN_API_C( OSStatus )
  696. USBNewInterfaceRef( 
  697.   USBPB *                 pb);
  698.  
  699.  
  700. /*
  701.  *  USBDisposeInterfaceRef()
  702.  *  
  703.  *  Availability:
  704.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  705.  *    CarbonLib:        not available
  706.  *    Mac OS X:         not available
  707.  */
  708. EXTERN_API_C( OSStatus )
  709. USBDisposeInterfaceRef( 
  710.   USBPB *                 pb);
  711.  
  712.  
  713. /*
  714.  *  USBConfigureInterface()
  715.  *  
  716.  *  Availability:
  717.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  718.  *    CarbonLib:        not available
  719.  *    Mac OS X:         not available
  720.  */
  721. EXTERN_API_C( OSStatus )
  722. USBConfigureInterface( 
  723.   USBPB *                 pb);
  724.  
  725.  
  726. /*
  727.  *  USBFindNextPipe()
  728.  *  
  729.  *  Availability:
  730.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  731.  *    CarbonLib:        not available
  732.  *    Mac OS X:         not available
  733.  */
  734. EXTERN_API_C( OSStatus )
  735. USBFindNextPipe( 
  736.   USBPB *                 pb);
  737.  
  738.  
  739. /*
  740.  *  USBSetPipePolicy()
  741.  *  
  742.  *  Availability:
  743.  *    Non-Carbon CFM:   available in USBServicesLib 1.4 or later
  744.  *    CarbonLib:        not available
  745.  *    Mac OS X:         not available
  746.  */
  747. EXTERN_API_C( OSStatus )
  748. USBSetPipePolicy( 
  749.   USBPB *                 pb);
  750.  
  751.  
  752. /* Dealing with descriptors. */
  753. /* Note most of this is temprorary */
  754. /*
  755.  *  USBGetConfigurationDescriptor()
  756.  *  
  757.  *  Availability:
  758.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  759.  *    CarbonLib:        not available
  760.  *    Mac OS X:         not available
  761.  */
  762. EXTERN_API_C( OSStatus )
  763. USBGetConfigurationDescriptor( 
  764.   USBPB *                 pb);
  765.  
  766.  
  767. /*
  768.  *  USBGetFullConfigurationDescriptor()
  769.  *  
  770.  *  Availability:
  771.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  772.  *    CarbonLib:        not available
  773.  *    Mac OS X:         not available
  774.  */
  775. EXTERN_API_C( OSStatus )
  776. USBGetFullConfigurationDescriptor( 
  777.   USBPB *                 pb);
  778.  
  779.  
  780. /*
  781.  *  USBGetStringDescriptor()
  782.  *  
  783.  *  Availability:
  784.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  785.  *    CarbonLib:        not available
  786.  *    Mac OS X:         not available
  787.  */
  788. EXTERN_API_C( OSStatus )
  789. USBGetStringDescriptor( 
  790.   USBPB *                 pb);
  791.  
  792.  
  793. /*
  794.  *  USBFindNextEndpointDescriptorImmediate()
  795.  *  
  796.  *  Availability:
  797.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  798.  *    CarbonLib:        not available
  799.  *    Mac OS X:         not available
  800.  */
  801. EXTERN_API_C( OSStatus )
  802. USBFindNextEndpointDescriptorImmediate( 
  803.   USBPB *                 pb);
  804.  
  805.  
  806. /*
  807.  *  USBFindNextInterfaceDescriptorImmediate()
  808.  *  
  809.  *  Availability:
  810.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  811.  *    CarbonLib:        not available
  812.  *    Mac OS X:         not available
  813.  */
  814. EXTERN_API_C( OSStatus )
  815. USBFindNextInterfaceDescriptorImmediate( 
  816.   USBPB *                 pb);
  817.  
  818.  
  819. /*
  820.  *  USBFindNextAssociatedDescriptor()
  821.  *  
  822.  *  Availability:
  823.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  824.  *    CarbonLib:        not available
  825.  *    Mac OS X:         not available
  826.  */
  827. EXTERN_API_C( OSStatus )
  828. USBFindNextAssociatedDescriptor( 
  829.   USBPB *                 pb);
  830.  
  831.  
  832.  
  833.  
  834. /* Utility functions */
  835. /*
  836.  *  USBResetDevice()
  837.  *  
  838.  *  Availability:
  839.  *    Non-Carbon CFM:   available in USBServicesLib 1.1 or later
  840.  *    CarbonLib:        not available
  841.  *    Mac OS X:         not available
  842.  */
  843. EXTERN_API_C( OSStatus )
  844. USBResetDevice( 
  845.   USBPB *                 pb);
  846.  
  847.  
  848. /*
  849.  *  USBPortStatus()
  850.  *  
  851.  *  Availability:
  852.  *    Non-Carbon CFM:   available in USBServicesLib 1.4 or later
  853.  *    CarbonLib:        not available
  854.  *    Mac OS X:         not available
  855.  */
  856. EXTERN_API_C( OSStatus )
  857. USBPortStatus( 
  858.   USBPB *                 pb);
  859.  
  860.  
  861. /*
  862.  *  USBSuspendDevice()
  863.  *  
  864.  *  Availability:
  865.  *    Non-Carbon CFM:   available in USBServicesLib 1.3 or later
  866.  *    CarbonLib:        not available
  867.  *    Mac OS X:         not available
  868.  */
  869. EXTERN_API_C( OSStatus )
  870. USBSuspendDevice( 
  871.   USBPB *                 pb);
  872.  
  873.  
  874. /*
  875.  *  USBResumeDeviceByReference()
  876.  *  
  877.  *  Availability:
  878.  *    Non-Carbon CFM:   available in USBServicesLib 1.3 or later
  879.  *    CarbonLib:        not available
  880.  *    Mac OS X:         not available
  881.  */
  882. EXTERN_API_C( OSStatus )
  883. USBResumeDeviceByReference( 
  884.   USBReference            refIn);
  885.  
  886.  
  887. /*
  888.  *  USBGetBandwidthAvailableByReference()
  889.  *  
  890.  *  Availability:
  891.  *    Non-Carbon CFM:   available in USBServicesLib 1.4 or later
  892.  *    CarbonLib:        not available
  893.  *    Mac OS X:         not available
  894.  */
  895. EXTERN_API_C( OSStatus )
  896. USBGetBandwidthAvailableByReference( 
  897.   USBReference            ref,
  898.   UInt32 *                avail);
  899.  
  900.  
  901. /*
  902.  *  USBGetFrameNumberImmediate()
  903.  *  
  904.  *  Availability:
  905.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  906.  *    CarbonLib:        not available
  907.  *    Mac OS X:         not available
  908.  */
  909. EXTERN_API_C( OSStatus )
  910. USBGetFrameNumberImmediate( 
  911.   USBPB *                 pb);
  912.  
  913.  
  914. /*
  915.  *  USBDelay()
  916.  *  
  917.  *  Availability:
  918.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  919.  *    CarbonLib:        not available
  920.  *    Mac OS X:         not available
  921.  */
  922. EXTERN_API_C( OSStatus )
  923. USBDelay( 
  924.   USBPB *                 pb);
  925.  
  926.  
  927. /*
  928.  *  USBSAbortQueuesByReference()
  929.  *  
  930.  *  Availability:
  931.  *    Non-Carbon CFM:   available in USBServicesLib 1.3 or later
  932.  *    CarbonLib:        not available
  933.  *    Mac OS X:         not available
  934.  */
  935. EXTERN_API_C( OSStatus )
  936. USBSAbortQueuesByReference( 
  937.   USBReference            ref);
  938.  
  939.  
  940. /*
  941.  *  USBAllocMem()
  942.  *  
  943.  *  Availability:
  944.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  945.  *    CarbonLib:        not available
  946.  *    Mac OS X:         not available
  947.  */
  948. EXTERN_API_C( OSStatus )
  949. USBAllocMem( 
  950.   USBPB *                 pb);
  951.  
  952.  
  953. /*
  954.  *  USBDeallocMem()
  955.  *  
  956.  *  Availability:
  957.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  958.  *    CarbonLib:        not available
  959.  *    Mac OS X:         not available
  960.  */
  961. EXTERN_API_C( OSStatus )
  962. USBDeallocMem( 
  963.   USBPB *                 pb);
  964.  
  965.  
  966. /* Expert interface functions */
  967. /*
  968.  *  USBExpertInstallInterfaceDriver()
  969.  *  
  970.  *  Availability:
  971.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  972.  *    CarbonLib:        not available
  973.  *    Mac OS X:         not available
  974.  */
  975. EXTERN_API_C( OSStatus )
  976. USBExpertInstallInterfaceDriver( 
  977.   USBDeviceRef            ref,
  978.   USBDeviceDescriptorPtr  desc,
  979.   USBInterfaceDescriptorPtr  interfacePtr,
  980.   USBReference            hubRef,
  981.   UInt32                  busPowerAvailable);
  982.  
  983.  
  984. /*
  985.  *  USBExpertRemoveInterfaceDriver()
  986.  *  
  987.  *  Availability:
  988.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  989.  *    CarbonLib:        not available
  990.  *    Mac OS X:         not available
  991.  */
  992. EXTERN_API_C( OSStatus )
  993. USBExpertRemoveInterfaceDriver( 
  994.   USBDeviceRef            ref);
  995.  
  996.  
  997. /*
  998.  *  USBExpertInstallDeviceDriver()
  999.  *  
  1000.  *  Availability:
  1001.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1002.  *    CarbonLib:        not available
  1003.  *    Mac OS X:         not available
  1004.  */
  1005. EXTERN_API_C( OSStatus )
  1006. USBExpertInstallDeviceDriver( 
  1007.   USBDeviceRef            ref,
  1008.   USBDeviceDescriptorPtr  desc,
  1009.   USBReference            hubRef,
  1010.   UInt32                  port,
  1011.   UInt32                  busPowerAvailable);
  1012.  
  1013.  
  1014. /*
  1015.  *  USBExpertRemoveDeviceDriver()
  1016.  *  
  1017.  *  Availability:
  1018.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1019.  *    CarbonLib:        not available
  1020.  *    Mac OS X:         not available
  1021.  */
  1022. EXTERN_API_C( OSStatus )
  1023. USBExpertRemoveDeviceDriver( 
  1024.   USBDeviceRef            ref);
  1025.  
  1026.  
  1027. /*
  1028.  *  USBExpertStatus()
  1029.  *  
  1030.  *  Availability:
  1031.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1032.  *    CarbonLib:        not available
  1033.  *    Mac OS X:         not available
  1034.  */
  1035. EXTERN_API_C( OSStatus )
  1036. USBExpertStatus( 
  1037.   USBDeviceRef            ref,
  1038.   void *                  pointer,
  1039.   UInt32                  value);
  1040.  
  1041.  
  1042. /*
  1043.  *  USBExpertFatalError()
  1044.  *  
  1045.  *  Availability:
  1046.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1047.  *    CarbonLib:        not available
  1048.  *    Mac OS X:         not available
  1049.  */
  1050. EXTERN_API_C( OSStatus )
  1051. USBExpertFatalError( 
  1052.   USBDeviceRef            ref,
  1053.   OSStatus                status,
  1054.   void *                  pointer,
  1055.   UInt32                  value);
  1056.  
  1057.  
  1058. /*
  1059.  *  USBExpertNotify()
  1060.  *  
  1061.  *  Availability:
  1062.  *    Non-Carbon CFM:   available in USBFamilyExpertLib 1.0 or later
  1063.  *    CarbonLib:        not available
  1064.  *    Mac OS X:         not available
  1065.  */
  1066. EXTERN_API_C( OSStatus )
  1067. USBExpertNotify( 
  1068.   void *                  note);
  1069.  
  1070.  
  1071. /*
  1072.  *  USBExpertStatusLevel()
  1073.  *  
  1074.  *  Availability:
  1075.  *    Non-Carbon CFM:   available in USBServicesLib 1.2 or later
  1076.  *    CarbonLib:        not available
  1077.  *    Mac OS X:         not available
  1078.  */
  1079. EXTERN_API_C( OSStatus )
  1080. USBExpertStatusLevel( 
  1081.   UInt32                  level,
  1082.   USBDeviceRef            ref,
  1083.   StringPtr               status,
  1084.   UInt32                  value);
  1085.  
  1086.  
  1087. /*
  1088.  *  USBExpertGetStatusLevel()
  1089.  *  
  1090.  *  Availability:
  1091.  *    Non-Carbon CFM:   available in USBServicesLib 1.3 or later
  1092.  *    CarbonLib:        not available
  1093.  *    Mac OS X:         not available
  1094.  */
  1095. EXTERN_API_C( UInt32 )
  1096. USBExpertGetStatusLevel( void );
  1097.  
  1098.  
  1099. /*
  1100.  *  USBExpertSetStatusLevel()
  1101.  *  
  1102.  *  Availability:
  1103.  *    Non-Carbon CFM:   available in USBServicesLib 1.3 or later
  1104.  *    CarbonLib:        not available
  1105.  *    Mac OS X:         not available
  1106.  */
  1107. EXTERN_API_C( void )
  1108. USBExpertSetStatusLevel( 
  1109.   UInt32                  level);
  1110.  
  1111.  
  1112.  
  1113.  
  1114. /*
  1115.  *  USBExpertSetDevicePowerStatus()
  1116.  *  
  1117.  *  Availability:
  1118.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1119.  *    CarbonLib:        not available
  1120.  *    Mac OS X:         not available
  1121.  */
  1122. EXTERN_API_C( OSStatus )
  1123. USBExpertSetDevicePowerStatus( 
  1124.   USBDeviceRef            ref,
  1125.   UInt32                  reserved1,
  1126.   UInt32                  reserved2,
  1127.   UInt32                  powerStatus,
  1128.   UInt32                  busPowerAvailable,
  1129.   UInt32                  busPowerNeeded);
  1130.  
  1131.  
  1132. #endif  /* CALL_NOT_IN_CARBON */
  1133.  
  1134. enum {
  1135.   kUSBDevicePower_PowerOK       = 0,
  1136.   kUSBDevicePower_BusPowerInsufficient = 1,
  1137.   kUSBDevicePower_BusPowerNotAllFeatures = 2,
  1138.   kUSBDevicePower_SelfPowerInsufficient = 3,
  1139.   kUSBDevicePower_SelfPowerNotAllFeatures = 4,
  1140.   kUSBDevicePower_HubPortOk     = 5,
  1141.   kUSBDevicePower_HubPortOverCurrent = 6,
  1142.   kUSBDevicePower_BusPoweredHubOnLowPowerPort = 7,
  1143.   kUSBDevicePower_BusPoweredHubToBusPoweredHub = 8,
  1144.   kUSBDevicePower_Reserved3     = 9,
  1145.   kUSBDevicePower_Reserved4     = 10
  1146. };
  1147.  
  1148.  
  1149. /* For hubs only */
  1150. #if CALL_NOT_IN_CARBON
  1151. /*
  1152.  *  USBHubAddDevice()
  1153.  *  
  1154.  *  Availability:
  1155.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1156.  *    CarbonLib:        not available
  1157.  *    Mac OS X:         not available
  1158.  */
  1159. EXTERN_API_C( OSStatus )
  1160. USBHubAddDevice( 
  1161.   USBPB *                 pb);
  1162.  
  1163.  
  1164. /*
  1165.  *  USBHubConfigurePipeZero()
  1166.  *  
  1167.  *  Availability:
  1168.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1169.  *    CarbonLib:        not available
  1170.  *    Mac OS X:         not available
  1171.  */
  1172. EXTERN_API_C( OSStatus )
  1173. USBHubConfigurePipeZero( 
  1174.   USBPB *                 pb);
  1175.  
  1176.  
  1177. /*
  1178.  *  USBHubSetAddress()
  1179.  *  
  1180.  *  Availability:
  1181.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1182.  *    CarbonLib:        not available
  1183.  *    Mac OS X:         not available
  1184.  */
  1185. EXTERN_API_C( OSStatus )
  1186. USBHubSetAddress( 
  1187.   USBPB *                 pb);
  1188.  
  1189.  
  1190. /*
  1191.  *  USBHubDeviceRemoved()
  1192.  *  
  1193.  *  Availability:
  1194.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1195.  *    CarbonLib:        not available
  1196.  *    Mac OS X:         not available
  1197.  */
  1198. EXTERN_API_C( OSStatus )
  1199. USBHubDeviceRemoved( 
  1200.   USBPB *                 pb);
  1201.  
  1202.  
  1203. /*
  1204.  *  USBMakeBMRequestType()
  1205.  *  
  1206.  *  Availability:
  1207.  *    Non-Carbon CFM:   available in USBServicesLib 1.0 or later
  1208.  *    CarbonLib:        not available
  1209.  *    Mac OS X:         not available
  1210.  */
  1211. EXTERN_API_C( UInt8 )
  1212. USBMakeBMRequestType( 
  1213.   UInt8                   direction,
  1214.   UInt8                   reqtype,
  1215.   UInt8                   recipient);
  1216.  
  1217.  
  1218. /*
  1219.  *  USBControlRequest()
  1220.  *  
  1221.  *  Availability:
  1222.  *    Non-Carbon CFM:   available in USBServicesLib 1.2 or later
  1223.  *    CarbonLib:        not available
  1224.  *    Mac OS X:         not available
  1225.  */
  1226. EXTERN_API_C( OSStatus )
  1227. USBControlRequest( 
  1228.   USBPB *                 pb);
  1229.  
  1230.  
  1231. #endif  /* CALL_NOT_IN_CARBON */
  1232.  
  1233. typedef UInt32                          USBLocationID;
  1234. enum {
  1235.   kUSBLocationNibbleFormat      = 0     /* Other values are reserved for future types (like when we have more than 16 ports per hub)*/
  1236. };
  1237.  
  1238.  
  1239. enum {
  1240.   kNoDeviceRef                  = -1
  1241. };
  1242.  
  1243. /* Status Level constants*/
  1244. /*
  1245. Level 1: Fatal errors
  1246. Level 2: General errors that may or may not effect operation
  1247. Level 3: General driver messages.  The "AddStatus" call that drivers use comes through as a level 3.  This is also the default level at boot time.
  1248. Level 4: Important status messages from the Expert and USL.
  1249. Level 5: General status messages from the Expert and USL.
  1250. */
  1251. enum {
  1252.   kUSBStatusLevelFatal          = 1,
  1253.   kUSBStatusLevelError          = 2,
  1254.   kUSBStatusLevelClient         = 3,
  1255.   kUSBStatusLevelGeneral        = 4,
  1256.   kUSBStatusLevelVerbose        = 5
  1257. };
  1258.  
  1259. /* Expert Notification Types*/
  1260.  
  1261. typedef UInt8 USBNotificationType;
  1262. enum {
  1263.   kNotifyAddDevice              = 0x00,
  1264.   kNotifyRemoveDevice           = 0x01,
  1265.   kNotifyAddInterface           = 0x02,
  1266.   kNotifyRemoveInterface        = 0x03,
  1267.   kNotifyGetDeviceDescriptor    = 0x04,
  1268.   kNotifyGetInterfaceDescriptor = 0x05,
  1269.   kNotifyGetNextDeviceByClass   = 0x06,
  1270.   kNotifyGetDriverConnectionID  = 0x07,
  1271.   kNotifyInstallDeviceNotification = 0x08,
  1272.   kNotifyRemoveDeviceNotification = 0x09,
  1273.   kNotifyDeviceRefToBusRef      = 0x0A,
  1274.   kNotifyDriverNotify           = 0x0C,
  1275.   kNotifyParentNotify           = 0x0D,
  1276.   kNotifyAnyEvent               = 0xFF,
  1277.   kNotifyPowerState             = 0x17,
  1278.   kNotifyStatus                 = 0x18,
  1279.   kNotifyFatalError             = 0x19,
  1280.   kNotifyStatusLevel            = 0x20
  1281. };
  1282.  
  1283. typedef USBNotificationType             USBDriverMessage;
  1284. /*
  1285.    USB Manager wildcard constants for USBGetNextDeviceByClass
  1286.    and USBInstallDeviceNotification.
  1287. */
  1288.  
  1289. typedef UInt16 USBManagerWildcard;
  1290. enum {
  1291.   kUSBAnyClass                  = 0xFFFF,
  1292.   kUSBAnySubClass               = 0xFFFF,
  1293.   kUSBAnyProtocol               = 0xFFFF,
  1294.   kUSBAnyVendor                 = 0xFFFF,
  1295.   kUSBAnyProduct                = 0xFFFF
  1296. };
  1297.  
  1298.  
  1299.  
  1300.  
  1301. struct ExpertNotificationData {
  1302.   USBNotificationType  notification;
  1303.   UInt8               filler[1];              /* unused due to 2-byte 68k alignment*/
  1304.   USBDeviceRef *      deviceRef;
  1305.   UInt32              busPowerAvailable;
  1306.   void *              data;
  1307.   UInt32              info1;
  1308.   UInt32              info2;
  1309. };
  1310. typedef struct ExpertNotificationData   ExpertNotificationData;
  1311. typedef ExpertNotificationData *        ExpertNotificationDataPtr;
  1312. /* Definition of function pointer passed in ExpertEntryProc*/
  1313. typedef CALLBACK_API_C( OSStatus , ExpertNotificationProcPtr )(ExpertNotificationDataPtr pNotificationData);
  1314. /* Definition of expert's callback installation function*/
  1315. typedef CALLBACK_API_C( OSStatus , ExpertEntryProcPtr )(ExpertNotificationProcPtr pExpertNotify);
  1316. /* Device Notification Callback Routine*/
  1317. typedef CALLBACK_API_C( void , USBDeviceNotificationCallbackProcPtr )(void *pb);
  1318. /* Device Notification Parameter Block*/
  1319.  
  1320. struct USBDeviceNotificationParameterBlock {
  1321.   UInt16              pbLength;
  1322.   UInt16              pbVersion;
  1323.   USBNotificationType  usbDeviceNotification;
  1324.   UInt8               reserved1[1];           /* needed because of 2-byte 68k alignment*/
  1325.   USBDeviceRef        usbDeviceRef;
  1326.   UInt16              usbClass;
  1327.   UInt16              usbSubClass;
  1328.   UInt16              usbProtocol;
  1329.   UInt16              usbVendor;
  1330.   UInt16              usbProduct;
  1331.   OSStatus            result;
  1332.   UInt32              token;
  1333.   USBDeviceNotificationCallbackProcPtr  callback;
  1334.   UInt32              refcon;
  1335. };
  1336. typedef struct USBDeviceNotificationParameterBlock USBDeviceNotificationParameterBlock;
  1337. typedef USBDeviceNotificationParameterBlock * USBDeviceNotificationParameterBlockPtr;
  1338. /* Definition of USBDriverNotificationCallback Routine*/
  1339. typedef CALLBACK_API_C( void , USBDriverNotificationCallbackPtr )(OSStatus status, UInt32 refcon);
  1340. /* Public Functions*/
  1341. #if CALL_NOT_IN_CARBON
  1342. /*
  1343.  *  USBGetVersion()
  1344.  *  
  1345.  *  Availability:
  1346.  *    Non-Carbon CFM:   available in USBServicesLib 1.3 or later
  1347.  *    CarbonLib:        not available
  1348.  *    Mac OS X:         not available
  1349.  */
  1350. EXTERN_API_C( UInt32 )
  1351. USBGetVersion( void );
  1352.  
  1353.  
  1354. /*
  1355.  *  USBGetNextDeviceByClass()
  1356.  *  
  1357.  *  Availability:
  1358.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1359.  *    CarbonLib:        not available
  1360.  *    Mac OS X:         not available
  1361.  */
  1362. EXTERN_API_C( OSStatus )
  1363. USBGetNextDeviceByClass( 
  1364.   USBDeviceRef *          deviceRef,
  1365.   CFragConnectionID *     connID,
  1366.   UInt16                  theClass,
  1367.   UInt16                  theSubClass,
  1368.   UInt16                  theProtocol);
  1369.  
  1370.  
  1371. /*
  1372.  *  USBGetDeviceDescriptor()
  1373.  *  
  1374.  *  Availability:
  1375.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1376.  *    CarbonLib:        not available
  1377.  *    Mac OS X:         not available
  1378.  */
  1379. EXTERN_API_C( OSStatus )
  1380. USBGetDeviceDescriptor( 
  1381.   USBDeviceRef *          deviceRef,
  1382.   USBDeviceDescriptor *   deviceDescriptor,
  1383.   UInt32                  size);
  1384.  
  1385.  
  1386. /*
  1387.  *  USBGetInterfaceDescriptor()
  1388.  *  
  1389.  *  Availability:
  1390.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1391.  *    CarbonLib:        not available
  1392.  *    Mac OS X:         not available
  1393.  */
  1394. EXTERN_API_C( OSStatus )
  1395. USBGetInterfaceDescriptor( 
  1396.   USBInterfaceRef *       interfaceRef,
  1397.   USBInterfaceDescriptor * interfaceDescriptor,
  1398.   UInt32                  size);
  1399.  
  1400.  
  1401. /*
  1402.  *  USBGetDriverConnectionID()
  1403.  *  
  1404.  *  Availability:
  1405.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1406.  *    CarbonLib:        not available
  1407.  *    Mac OS X:         not available
  1408.  */
  1409. EXTERN_API_C( OSStatus )
  1410. USBGetDriverConnectionID( 
  1411.   USBDeviceRef *          deviceRef,
  1412.   CFragConnectionID *     connID);
  1413.  
  1414.  
  1415. /*
  1416.  *  USBInstallDeviceNotification()
  1417.  *  
  1418.  *  Availability:
  1419.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1420.  *    CarbonLib:        not available
  1421.  *    Mac OS X:         not available
  1422.  */
  1423. EXTERN_API_C( void )
  1424. USBInstallDeviceNotification( 
  1425.   USBDeviceNotificationParameterBlock * pb);
  1426.  
  1427.  
  1428. /*
  1429.  *  USBRemoveDeviceNotification()
  1430.  *  
  1431.  *  Availability:
  1432.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1433.  *    CarbonLib:        not available
  1434.  *    Mac OS X:         not available
  1435.  */
  1436. EXTERN_API_C( OSStatus )
  1437. USBRemoveDeviceNotification( 
  1438.   UInt32                  token);
  1439.  
  1440.  
  1441. /*
  1442.  *  USBDeviceRefToBusRef()
  1443.  *  
  1444.  *  Availability:
  1445.  *    Non-Carbon CFM:   available in USBManagerLib 1.0 or later
  1446.  *    CarbonLib:        not available
  1447.  *    Mac OS X:         not available
  1448.  */
  1449. EXTERN_API_C( OSStatus )
  1450. USBDeviceRefToBusRef( 
  1451.   USBDeviceRef *          deviceRef,
  1452.   USBBusRef *             busRef);
  1453.  
  1454.  
  1455. /*
  1456.  *  USBDriverNotify()
  1457.  *  
  1458.  *  Availability:
  1459.  *    Non-Carbon CFM:   available in USBManagerLib 1.1 or later
  1460.  *    CarbonLib:        not available
  1461.  *    Mac OS X:         not available
  1462.  */
  1463. EXTERN_API_C( OSStatus )
  1464. USBDriverNotify( 
  1465.   USBReference            reference,
  1466.   USBDriverMessage        mesg,
  1467.   UInt32                  refcon,
  1468.   USBDriverNotificationCallbackPtr  callback);
  1469.  
  1470.  
  1471. /*
  1472.  *  USBExpertNotifyParent()
  1473.  *  
  1474.  *  Availability:
  1475.  *    Non-Carbon CFM:   available in USBManagerLib 1.1 or later
  1476.  *    CarbonLib:        not available
  1477.  *    Mac OS X:         not available
  1478.  */
  1479. EXTERN_API_C( OSStatus )
  1480. USBExpertNotifyParent( 
  1481.   USBReference            reference,
  1482.   void *                  pointer);
  1483.  
  1484.  
  1485. /*
  1486.  *  USBAddDriverForFSSpec()
  1487.  *  
  1488.  *  Availability:
  1489.  *    Non-Carbon CFM:   available in USBManagerLib 1.3 or later
  1490.  *    CarbonLib:        not available
  1491.  *    Mac OS X:         not available
  1492.  */
  1493. EXTERN_API_C( OSStatus )
  1494. USBAddDriverForFSSpec( 
  1495.   USBReference            reference,
  1496.   FSSpec *                fileSpec);
  1497.  
  1498.  
  1499. /*
  1500.  *  USBAddShimFromDisk()
  1501.  *  
  1502.  *  Availability:
  1503.  *    Non-Carbon CFM:   available in USBManagerLib 1.4 or later
  1504.  *    CarbonLib:        not available
  1505.  *    Mac OS X:         not available
  1506.  */
  1507. EXTERN_API_C( OSStatus )
  1508. USBAddShimFromDisk( 
  1509.   FSSpec *                shimFilePtr);
  1510.  
  1511.  
  1512. /*
  1513.  *  USBReferenceToRegEntry()
  1514.  *  
  1515.  *  Availability:
  1516.  *    Non-Carbon CFM:   available in USBManagerLib 1.4 or later
  1517.  *    CarbonLib:        not available
  1518.  *    Mac OS X:         not available
  1519.  */
  1520. EXTERN_API_C( OSStatus )
  1521. USBReferenceToRegEntry( 
  1522.   RegEntryID *            parentEntry,
  1523.   USBDeviceRef            parentDeviceRef);
  1524.  
  1525.  
  1526. /*
  1527.  *  USBConfigureADBShim()
  1528.  *  
  1529.  *  Availability:
  1530.  *    Non-Carbon CFM:   available in USBManagerLib 1.4 or later
  1531.  *    CarbonLib:        not available
  1532.  *    Mac OS X:         not available
  1533.  */
  1534. EXTERN_API_C( OSStatus )
  1535. USBConfigureADBShim( 
  1536.   UInt32                  inCommandID,
  1537.   void *                  arg1,
  1538.   void *                  arg2);
  1539.  
  1540.  
  1541.  
  1542. #endif  /* CALL_NOT_IN_CARBON */
  1543.  
  1544. typedef CALLBACK_API_C( void , HIDInterruptProcPtr )(UInt32 refcon, void *theData);
  1545. typedef CALLBACK_API_C( void , HIDNotificationProcPtr )(UInt32 refcon, UInt32 reportSize, void *theReport, USBReference theInterfaceRef);
  1546. /* HID Install Interrupt prototype*/
  1547. typedef CALLBACK_API_C( OSStatus , USBHIDInstallInterruptProcPtr )(HIDInterruptProcPtr pInterruptProc, UInt32 refcon);
  1548. /* HID Poll Device prototype*/
  1549. typedef CALLBACK_API_C( OSStatus , USBHIDPollDeviceProcPtr )(void  );
  1550. /* HID Control Device prototype*/
  1551. typedef CALLBACK_API_C( OSStatus , USBHIDControlDeviceProcPtr )(UInt32 theControlSelector, void *theControlData);
  1552. /* HID Get Device Info prototype*/
  1553. typedef CALLBACK_API_C( OSStatus , USBHIDGetDeviceInfoProcPtr )(UInt32 theInfoSelector, void *theInfo);
  1554. /* HID Enter Polled Mode prototype*/
  1555. typedef CALLBACK_API_C( OSStatus , USBHIDEnterPolledModeProcPtr )(void  );
  1556. /* HID Exit Polled Mode prototype*/
  1557. typedef CALLBACK_API_C( OSStatus , USBHIDExitPolledModeProcPtr )(void  );
  1558. /* HID Install Notification prototype*/
  1559. typedef CALLBACK_API_C( OSStatus , USBHIDInstallNotificationProcPtr )(HIDNotificationProcPtr pNotificationProc, UInt32 refcon);
  1560. enum {
  1561.   kHIDStandardDispatchVersion   = 0,
  1562.   kHIDReservedDispatchVersion   = 1,
  1563.   kHIDNotificationDispatchVersion = 2,
  1564.   kHIDCurrentDispatchVersion    = 2
  1565. };
  1566.  
  1567.  
  1568.  
  1569. struct USBHIDRev2DispatchTable {
  1570.   UInt32              hidDispatchVersion;
  1571.   USBHIDInstallInterruptProcPtr  pUSBHIDInstallInterrupt;
  1572.   USBHIDPollDeviceProcPtr  pUSBHIDPollDevice;
  1573.   USBHIDControlDeviceProcPtr  pUSBHIDControlDevice;
  1574.   USBHIDGetDeviceInfoProcPtr  pUSBHIDGetDeviceInfo;
  1575.   USBHIDEnterPolledModeProcPtr  pUSBHIDEnterPolledMode;
  1576.   USBHIDExitPolledModeProcPtr  pUSBHIDExitPolledMode;
  1577.   USBHIDInstallNotificationProcPtr  pUSBHIDInstallNotification;
  1578. };
  1579. typedef struct USBHIDRev2DispatchTable  USBHIDRev2DispatchTable;
  1580. typedef USBHIDRev2DispatchTable *       USBHIDRev2DispatchTablePtr;
  1581.  
  1582. struct USBHIDModuleDispatchTable {
  1583.   UInt32              hidDispatchVersion;
  1584.   USBHIDInstallInterruptProcPtr  pUSBHIDInstallInterrupt;
  1585.   USBHIDPollDeviceProcPtr  pUSBHIDPollDevice;
  1586.   USBHIDControlDeviceProcPtr  pUSBHIDControlDevice;
  1587.   USBHIDGetDeviceInfoProcPtr  pUSBHIDGetDeviceInfo;
  1588.   USBHIDEnterPolledModeProcPtr  pUSBHIDEnterPolledMode;
  1589.   USBHIDExitPolledModeProcPtr  pUSBHIDExitPolledMode;
  1590. };
  1591. typedef struct USBHIDModuleDispatchTable USBHIDModuleDispatchTable;
  1592. typedef USBHIDModuleDispatchTable *     USBHIDModuleDispatchTablePtr;
  1593. /*  Prototypes Tue, Mar 17, 1998 4:54:30 PM */
  1594. #if CALL_NOT_IN_CARBON
  1595. /*
  1596.  *  USBHIDInstallInterrupt()
  1597.  *  
  1598.  *  Availability:
  1599.  *    Non-Carbon CFM:   not available
  1600.  *    CarbonLib:        not available
  1601.  *    Mac OS X:         not available
  1602.  */
  1603. EXTERN_API_C( OSStatus )
  1604. USBHIDInstallInterrupt( 
  1605.   HIDInterruptProcPtr     HIDInterruptFunction,
  1606.   UInt32                  refcon);
  1607.  
  1608.  
  1609. /*
  1610.  *  USBHIDPollDevice()
  1611.  *  
  1612.  *  Availability:
  1613.  *    Non-Carbon CFM:   not available
  1614.  *    CarbonLib:        not available
  1615.  *    Mac OS X:         not available
  1616.  */
  1617. EXTERN_API_C( OSStatus )
  1618. USBHIDPollDevice( void );
  1619.  
  1620.  
  1621. /*
  1622.  *  USBHIDControlDevice()
  1623.  *  
  1624.  *  Availability:
  1625.  *    Non-Carbon CFM:   not available
  1626.  *    CarbonLib:        not available
  1627.  *    Mac OS X:         not available
  1628.  */
  1629. EXTERN_API_C( OSStatus )
  1630. USBHIDControlDevice( 
  1631.   UInt32                  theControlSelector,
  1632.   void *                  theControlData);
  1633.  
  1634.  
  1635. /*
  1636.  *  USBHIDGetDeviceInfo()
  1637.  *  
  1638.  *  Availability:
  1639.  *    Non-Carbon CFM:   not available
  1640.  *    CarbonLib:        not available
  1641.  *    Mac OS X:         not available
  1642.  */
  1643. EXTERN_API_C( OSStatus )
  1644. USBHIDGetDeviceInfo( 
  1645.   UInt32                  theInfoSelector,
  1646.   void *                  theInfo);
  1647.  
  1648.  
  1649. /*
  1650.  *  USBHIDEnterPolledMode()
  1651.  *  
  1652.  *  Availability:
  1653.  *    Non-Carbon CFM:   not available
  1654.  *    CarbonLib:        not available
  1655.  *    Mac OS X:         not available
  1656.  */
  1657. EXTERN_API_C( OSStatus )
  1658. USBHIDEnterPolledMode( void );
  1659.  
  1660.  
  1661. /*
  1662.  *  USBHIDExitPolledMode()
  1663.  *  
  1664.  *  Availability:
  1665.  *    Non-Carbon CFM:   not available
  1666.  *    CarbonLib:        not available
  1667.  *    Mac OS X:         not available
  1668.  */
  1669. EXTERN_API_C( OSStatus )
  1670. USBHIDExitPolledMode( void );
  1671.  
  1672.  
  1673. /*
  1674.  *  USBHIDInstallNotification()
  1675.  *  
  1676.  *  Availability:
  1677.  *    Non-Carbon CFM:   not available
  1678.  *    CarbonLib:        not available
  1679.  *    Mac OS X:         not available
  1680.  */
  1681. EXTERN_API_C( OSStatus )
  1682. USBHIDInstallNotification( 
  1683.   HIDNotificationProcPtr  HIDNotificationFunction,
  1684.   UInt32                  refcon);
  1685.  
  1686.  
  1687. /*
  1688.  *  HIDNotification()
  1689.  *  
  1690.  *  Availability:
  1691.  *    Non-Carbon CFM:   not available
  1692.  *    CarbonLib:        not available
  1693.  *    Mac OS X:         not available
  1694.  */
  1695. EXTERN_API_C( void )
  1696. HIDNotification( 
  1697.   UInt32                  devicetype,
  1698.   UInt8                   NewHIDData[],
  1699.   UInt8                   OldHIDData[]);
  1700.  
  1701.  
  1702. #endif  /* CALL_NOT_IN_CARBON */
  1703.  
  1704. enum {
  1705.   kHIDRqGetReport               = 1,
  1706.   kHIDRqGetIdle                 = 2,
  1707.   kHIDRqGetProtocol             = 3,
  1708.   kHIDRqSetReport               = 9,
  1709.   kHIDRqSetIdle                 = 10,
  1710.   kHIDRqSetProtocol             = 11
  1711. };
  1712.  
  1713. enum {
  1714.   kHIDRtInputReport             = 1,
  1715.   kHIDRtOutputReport            = 2,
  1716.   kHIDRtFeatureReport           = 3
  1717. };
  1718.  
  1719. enum {
  1720.   kHIDBootProtocolValue         = 0,
  1721.   kHIDReportProtocolValue       = 1
  1722. };
  1723.  
  1724. enum {
  1725.   kHIDKeyboardInterfaceProtocol = 1,
  1726.   kHIDMouseInterfaceProtocol    = 2
  1727. };
  1728.  
  1729. enum {
  1730.   kHIDSetLEDStateByBits         = 1,
  1731.   kHIDSetLEDStateByBitMask      = 1,
  1732.   kHIDSetLEDStateByIDNumber     = 2,
  1733.   kHIDRemoveInterruptHandler    = 3,
  1734.   kHIDEnableDemoMode            = 4,
  1735.   kHIDDisableDemoMode           = 5,
  1736.   kHIDRemoveNotification        = 0x1000
  1737. };
  1738.  
  1739. enum {
  1740.   kHIDGetLEDStateByBits         = 1,    /* not supported in 1.0 of keyboard module*/
  1741.   kHIDGetLEDStateByBitMask      = 1,    /* not supported in 1.0 of keyboard module*/
  1742.   kHIDGetLEDStateByIDNumber     = 2,
  1743.   kHIDGetDeviceCountryCode      = 3,    /* not supported in 1.0 HID modules*/
  1744.   kHIDGetDeviceUnitsPerInch     = 4,    /* only supported in mouse HID module*/
  1745.   kHIDGetInterruptHandler       = 5,
  1746.   kHIDGetCurrentKeys            = 6,    /* only supported in keyboard HID module*/
  1747.   kHIDGetInterruptRefcon        = 7,
  1748.   kHIDGetVendorID               = 8,
  1749.   kHIDGetProductID              = 9
  1750. };
  1751.  
  1752.  
  1753. enum {
  1754.   kNumLockLED                   = 0,
  1755.   kCapsLockLED                  = 1,
  1756.   kScrollLockLED                = 2,
  1757.   kComposeLED                   = 3,
  1758.   kKanaLED                      = 4
  1759. };
  1760.  
  1761. enum {
  1762.   kNumLockLEDMask               = 1 << kNumLockLED,
  1763.   kCapsLockLEDMask              = 1 << kCapsLockLED,
  1764.   kScrollLockLEDMask            = 1 << kScrollLockLED,
  1765.   kComposeLEDMask               = 1 << kComposeLED,
  1766.   kKanaLEDMask                  = 1 << kKanaLED
  1767. };
  1768.  
  1769. enum {
  1770.   kUSBCapsLockKey               = 0x39,
  1771.   kUSBNumLockKey                = 0x53,
  1772.   kUSBScrollLockKey             = 0x47
  1773. };
  1774.  
  1775.  
  1776. struct USBMouseData {
  1777.   UInt16              buttons;
  1778.   SInt16              XDelta;
  1779.   SInt16              YDelta;
  1780. };
  1781. typedef struct USBMouseData             USBMouseData;
  1782. typedef USBMouseData *                  USBMouseDataPtr;
  1783.  
  1784. struct USBKeyboardData {
  1785.   UInt16              keycount;
  1786.   UInt16              usbkeycode[32];
  1787. };
  1788. typedef struct USBKeyboardData          USBKeyboardData;
  1789. typedef USBKeyboardData *               USBKeyboardDataPtr;
  1790.  
  1791. union USBHIDData {
  1792.   USBKeyboardData     kbd;
  1793.   USBMouseData        mouse;
  1794. };
  1795. typedef union USBHIDData                USBHIDData;
  1796. typedef USBHIDData *                    USBHIDDataPtr;
  1797. #if CALL_NOT_IN_CARBON
  1798. /*
  1799.  *  StartCompoundClassDriver()
  1800.  *  
  1801.  *  Availability:
  1802.  *    Non-Carbon CFM:   not available
  1803.  *    CarbonLib:        not available
  1804.  *    Mac OS X:         not available
  1805.  */
  1806. EXTERN_API_C( void )
  1807. StartCompoundClassDriver( 
  1808.   USBDeviceRef            device,
  1809.   UInt16                  classID,
  1810.   UInt16                  subClass);
  1811.  
  1812.  
  1813. #endif  /* CALL_NOT_IN_CARBON */
  1814.  
  1815. enum {
  1816.   kUSBCompositeClass            = 0,
  1817.   kUSBAudioClass                = 1,
  1818.   kUSBCommClass                 = 2,
  1819.   kUSBHIDClass                  = 3,
  1820.   kUSBDisplayClass              = 4,
  1821.   kUSBPrintingClass             = 7,
  1822.   kUSBMassStorageClass          = 8,
  1823.   kUSBHubClass                  = 9,
  1824.   kUSBDataClass                 = 10,
  1825.   kUSBVendorSpecificClass       = 0xFF
  1826. };
  1827.  
  1828. enum {
  1829.   kUSBCompositeSubClass         = 0,
  1830.   kUSBHubSubClass               = 1,
  1831.   kUSBPrinterSubclass           = 1,
  1832.   kUSBVendorSpecificSubClass    = 0xFF
  1833. };
  1834.  
  1835. enum {
  1836.   kUSBHIDInterfaceClass         = 0x03
  1837. };
  1838.  
  1839. enum {
  1840.   kUSBNoInterfaceSubClass       = 0x00,
  1841.   kUSBBootInterfaceSubClass     = 0x01
  1842. };
  1843.  
  1844. enum {
  1845.   kUSBNoInterfaceProtocol       = 0x00,
  1846.   kUSBKeyboardInterfaceProtocol = 0x01,
  1847.   kUSBMouseInterfaceProtocol    = 0x02,
  1848.   kUSBVendorSpecificProtocol    = 0xFF
  1849. };
  1850.  
  1851. enum {
  1852.   kUSBPrinterUnidirectionalProtocol = 0x01,
  1853.   kUSBPrinterBidirectionalProtocol = 0x02
  1854. };
  1855.  
  1856.  
  1857. enum {
  1858.   kServiceCategoryUSB           = FOUR_CHAR_CODE('usb ') /* USB*/
  1859. };
  1860.  
  1861. enum {
  1862.   kUSBDriverFileType            = FOUR_CHAR_CODE('ndrv'),
  1863.   kUSBDriverRsrcType            = FOUR_CHAR_CODE('usbd'),
  1864.   kUSBShimRsrcType              = FOUR_CHAR_CODE('usbs')
  1865. };
  1866.  
  1867. enum {
  1868.   kTheUSBDriverDescriptionSignature = FOUR_CHAR_CODE('usbd')
  1869. };
  1870.  
  1871. enum {
  1872.   kInitialUSBDriverDescriptor   = 0
  1873. };
  1874.  
  1875.  
  1876. typedef UInt32                          USBDriverDescVersion;
  1877. /*  Driver Loading Options*/
  1878.  
  1879. typedef UInt32 USBDriverLoadingOptions;
  1880. enum {
  1881.   kUSBDoNotMatchGenericDevice   = 0x00000001, /* Driver's VendorID must match Device's VendorID*/
  1882.   kUSBDoNotMatchInterface       = 0x00000002, /* Do not load this driver as an interface driver.*/
  1883.   kUSBProtocolMustMatch         = 0x00000004, /* Do not load this driver if protocol field doesn't match.*/
  1884.   kUSBInterfaceMatchOnly        = 0x00000008 /* Only load this driver as an interface driver.*/
  1885. };
  1886.  
  1887. enum {
  1888.   kClassDriverPluginVersion     = 0x00001100
  1889. };
  1890.  
  1891.  
  1892.  
  1893.  
  1894. struct USBDeviceInfo {
  1895.   UInt16              usbVendorID;            /* USB Vendor ID*/
  1896.   UInt16              usbProductID;           /* USB Product ID.*/
  1897.   UInt16              usbDeviceReleaseNumber; /* Release Number of Device*/
  1898.   UInt16              usbDeviceProtocol;      /* Protocol Info.*/
  1899. };
  1900. typedef struct USBDeviceInfo            USBDeviceInfo;
  1901. typedef USBDeviceInfo *                 USBDeviceInfoPtr;
  1902.  
  1903. struct USBInterfaceInfo {
  1904.   UInt8               usbConfigValue;         /* Configuration Value*/
  1905.   UInt8               usbInterfaceNum;        /* Interface Number*/
  1906.   UInt8               usbInterfaceClass;      /* Interface Class*/
  1907.   UInt8               usbInterfaceSubClass;   /* Interface SubClass*/
  1908.   UInt8               usbInterfaceProtocol;   /* Interface Protocol*/
  1909. };
  1910. typedef struct USBInterfaceInfo         USBInterfaceInfo;
  1911. typedef USBInterfaceInfo *              USBInterfaceInfoPtr;
  1912.  
  1913. struct USBDriverType {
  1914.   Str31               nameInfoStr;            /* Driver's name when loading into the Name Registry.*/
  1915.   UInt8               usbDriverClass;         /* USB Class this driver belongs to.*/
  1916.   UInt8               usbDriverSubClass;      /* Module type*/
  1917.   NumVersion          usbDriverVersion;       /* Class driver version number.*/
  1918. };
  1919. typedef struct USBDriverType            USBDriverType;
  1920. typedef USBDriverType *                 USBDriverTypePtr;
  1921.  
  1922. struct USBDriverDescription {
  1923.   OSType              usbDriverDescSignature; /* Signature field of this structure.*/
  1924.   USBDriverDescVersion  usbDriverDescVersion; /* Version of this data structure.*/
  1925.   USBDeviceInfo       usbDeviceInfo;          /* Product & Vendor Info*/
  1926.   USBInterfaceInfo    usbInterfaceInfo;       /* Interface info*/
  1927.   USBDriverType       usbDriverType;          /* Driver Info.*/
  1928.   USBDriverLoadingOptions  usbDriverLoadingOptions; /* Options for class driver loading.*/
  1929. };
  1930. typedef struct USBDriverDescription     USBDriverDescription;
  1931. typedef USBDriverDescription *          USBDriverDescriptionPtr;
  1932. /*
  1933.    Dispatch Table
  1934.    Definition of class driver's HW Validation proc.
  1935. */
  1936. typedef CALLBACK_API_C( OSStatus , USBDValidateHWProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  1937. /*
  1938.    Definition of class driver's device initialization proc.
  1939.    Called if the driver is being loaded for a device
  1940. */
  1941. typedef CALLBACK_API_C( OSStatus , USBDInitializeDeviceProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  1942. /* Definition of class driver's interface initialization proc.*/
  1943. typedef CALLBACK_API_C( OSStatus , USBDInitializeInterfaceProcPtr )(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDevice, USBInterfaceRef interfaceRef);
  1944. /* Definition of class driver's finalization proc.*/
  1945. typedef CALLBACK_API_C( OSStatus , USBDFinalizeProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  1946.  
  1947. typedef UInt32 USBDriverNotification;
  1948. enum {
  1949.   kNotifySystemSleepRequest     = 0x00000001,
  1950.   kNotifySystemSleepDemand      = 0x00000002,
  1951.   kNotifySystemSleepWakeUp      = 0x00000003,
  1952.   kNotifySystemSleepRevoke      = 0x00000004,
  1953.   kNotifyHubEnumQuery           = 0x00000006,
  1954.   kNotifyChildMessage           = 0x00000007,
  1955.   kNotifyExpertTerminating      = 0x00000008,
  1956.   kNotifyDriverBeingRemoved     = 0x0000000B,
  1957.   kNotifyAllowROMDriverRemoval  = 0x0000000E
  1958. };
  1959.  
  1960. /*
  1961.    Definition of driver's notification proc.      
  1962.    Added refcon for 1.1 version of dispatch table
  1963. */
  1964. typedef CALLBACK_API_C( OSStatus , USBDDriverNotifyProcPtr )(USBDriverNotification notification, void *pointer, UInt32 refcon);
  1965.  
  1966. struct USBClassDriverPluginDispatchTable {
  1967.   UInt32              pluginVersion;
  1968.   USBDValidateHWProcPtr  validateHWProc;      /* Proc for driver to verify proper HW*/
  1969.   USBDInitializeDeviceProcPtr  initializeDeviceProc; /* Proc that initializes the class driver.*/
  1970.   USBDInitializeInterfaceProcPtr  initializeInterfaceProc; /* Proc that initializes a particular interface in the class driver.*/
  1971.   USBDFinalizeProcPtr  finalizeProc;          /* Proc that finalizes the class driver.*/
  1972.   USBDDriverNotifyProcPtr  notificationProc;  /* Proc to pass notifications to the driver.*/
  1973. };
  1974. typedef struct USBClassDriverPluginDispatchTable USBClassDriverPluginDispatchTable;
  1975. typedef USBClassDriverPluginDispatchTable * USBClassDriverPluginDispatchTablePtr;
  1976. /* Shim Defines*/
  1977. enum {
  1978.   kTheUSBShimDescriptionSignature = FOUR_CHAR_CODE('usbs')
  1979. };
  1980.  
  1981.  
  1982. typedef UInt32 USBShimDescVersion;
  1983. enum {
  1984.   kCurrentUSBShimDescVers       = 0x0100
  1985. };
  1986.  
  1987. /*  Shim Loading Options*/
  1988.  
  1989. typedef UInt32 USBShimLoadingOptions;
  1990. enum {
  1991.   kUSBRegisterShimAsSharedLibrary = 0x00000001 /* Driver's VendorID must match Device's VendorID*/
  1992. };
  1993.  
  1994.  
  1995. struct USBShimDescription {
  1996.   OSType              usbShimDescSignature;   /* Signature field of this structure.*/
  1997.   USBShimDescVersion  usbShimDescVersion;     /* Version of this data structure.*/
  1998.   USBShimLoadingOptions  usbDriverLoadingOptions; /* Options for shim loading.*/
  1999.   Str63               libraryName;            /* For optional shared library registration*/
  2000. };
  2001. typedef struct USBShimDescription       USBShimDescription;
  2002. typedef USBShimDescription *            USBShimDescriptionPtr;
  2003. /* Hub defines*/
  2004.  
  2005. enum {
  2006.   kUSBHubDescriptorType         = 0x29
  2007. };
  2008.  
  2009. enum {
  2010.                                         /* Hub features */
  2011.   kUSBHubLocalPowerChangeFeature = 0,
  2012.   kUSBHubOverCurrentChangeFeature = 1,  /* port features */
  2013.   kUSBHubPortConnectionFeature  = 0,
  2014.   kUSBHubPortEnableFeature      = 1,
  2015.   kUSBHubPortSuspendFeature     = 2,
  2016.   kUSBHubPortOverCurrentFeature = 3,
  2017.   kUSBHubPortResetFeature       = 4,
  2018.   kUSBHubPortPowerFeature       = 8,
  2019.   kUSBHubPortLowSpeedFeature    = 9,
  2020.   kUSBHubPortConnectionChangeFeature = 16,
  2021.   kUSBHubPortEnableChangeFeature = 17,
  2022.   kUSBHubPortSuspendChangeFeature = 18,
  2023.   kUSBHubPortOverCurrentChangeFeature = 19,
  2024.   kUSBHubPortResetChangeFeature = 20
  2025. };
  2026.  
  2027.  
  2028. enum {
  2029.   kHubPortConnection            = 1,
  2030.   kHubPortEnabled               = 2,
  2031.   kHubPortSuspend               = 4,
  2032.   kHubPortOverCurrent           = 8,
  2033.   kHubPortBeingReset            = 16,
  2034.   kHubPortPower                 = 0x0100,
  2035.   kHubPortSpeed                 = 0x0200
  2036. };
  2037.  
  2038. enum {
  2039.   kHubLocalPowerStatus          = 1,
  2040.   kHubOverCurrentIndicator      = 2,
  2041.   kHubLocalPowerStatusChange    = 1,
  2042.   kHubOverCurrentIndicatorChange = 2
  2043. };
  2044.  
  2045. enum {
  2046.   off                           = false,
  2047.   on                            = true
  2048. };
  2049.  
  2050.  
  2051.  
  2052. struct hubDescriptor {
  2053.                                               /* See usbDoc pg 250?? */
  2054.   UInt8               dummy;                  /* to align charcteristics */
  2055.  
  2056.   UInt8               length;
  2057.   UInt8               hubType;
  2058.   UInt8               numPorts;
  2059.  
  2060.   UInt16              characteristics;
  2061.   UInt8               powerOnToGood;          /* Port settling time, in 2ms */
  2062.   UInt8               hubCurrent;
  2063.  
  2064.                                               /* These are received packed, will have to be unpacked */
  2065.   UInt8               removablePortFlags[8];
  2066.   UInt8               pwrCtlPortFlags[8];
  2067. };
  2068. typedef struct hubDescriptor            hubDescriptor;
  2069.  
  2070.  
  2071.  
  2072. #if PRAGMA_STRUCT_ALIGN
  2073.     #pragma options align=reset
  2074. #elif PRAGMA_STRUCT_PACKPUSH
  2075.     #pragma pack(pop)
  2076. #elif PRAGMA_STRUCT_PACK
  2077.     #pragma pack()
  2078. #endif
  2079.  
  2080. #ifdef PRAGMA_IMPORT_OFF
  2081. #pragma import off
  2082. #elif PRAGMA_IMPORT
  2083. #pragma import reset
  2084. #endif
  2085.  
  2086. #ifdef __cplusplus
  2087. }
  2088. #endif
  2089.  
  2090. #endif /* __USB__ */
  2091.  
  2092.